<?php

!defined('FSDKP') && exit('error: Access Denied');

require_once('func.php');
require_once('core.php');

if(!file_exists(APP_ROOT."caches/install.lock")) {
  exit('Welcome to FSDKP. Please <a href="_install/index.php">install</a> first');
}

require_once(APP_ROOT."caches/config.php");

session_start();

if(!$theme) { $theme = 'default'; }
define('ROOT_WEB',   APP_ROOT."templates/$theme/");
define('ROOT_CACHE', APP_ROOT."caches/themes/$theme/");
define('ROOT_THEME', APP_ROOT."templates/$theme/");
if(!defined('AUTH')) { define('AUTH', 'fsdkp');}

date_default_timezone_set('Asia/Shanghai');

(isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) && exit('error : GLOBALS');
$_FILES  = addslashes_deep($_FILES);
$_SERVER = addslashes_deep($_SERVER);
if (!get_magic_quotes_gpc()) {
  $_GET     = addslashes_deep($_GET);
  $_POST    = addslashes_deep($_POST);
  $_COOKIE  = addslashes_deep($_COOKIE);
  $_REQUEST = addslashes_deep($_REQUEST);
}

define('WEB_URL',   getURL());
define('WEB_URI',   getURI());
define('WEB_SURL',  getSURL());

@include(ROOT_THEME.'zh_CN.php');
setL($LANG);

if($theme) {
  C('Template',array(
    'theme' => ROOT_THEME,
    'cache' => ROOT_CACHE
  ));
}

if($sqlite) {
  $db = C('Sqlite',array(
    'dbhost'   => APP_ROOT . "caches/" . $dbhost
  ));
  $dbhost = '';
}

if($mysql) {
  $db = C('Mysql',array(
    'dbhost'   => $dbhost,
    'dbuser'   => $dbuser,
    'dbpw'     => $dbpw,
    'dbname'   => $dbname,
    'dbpre'    => $dbpre,
    'filedir'  => APP_ROOT . "caches/dbcache/"
  ));
  $dbhost = $dbuser = $dbpw = $dbname = '';
}

C('Upload',array(
  'save_dir'   => APP_ROOT . "caches/upload/"
));

C('Cache',array(
  'cache_dir'   => APP_ROOT . "caches/dbcache/"
));


?>